package com.example.VolunteerBank.mapper;

import com.example.VolunteerBank.pojo.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {

    //根据用户id查询文章分类
    @Select("select * from category where create_user = #{createUser}")
    List<Category> listByUserId(Integer createUser);

    //新增文章分类
    @Insert("insert into category(category_name, category_alias, create_user, create_time, update_time) VALUES (#{categoryName}, #{categoryAlias}, #{createUser}, #{createTime}, #{updateTime})")
    void add(Category category);

    //更新文章分类
    void update(Category category);

    //获取文章分类详情
    @Select("select * from category where id = #{id}")
    Category findById(Integer id);

    //删除文章分类
    @Delete("delete from category where id = #{id}")
    void delete(Integer id);
}
